{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = \"abcd\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'bc', 'c', 'ab', 'b', 'a', 'bcd', 'd', 'abc', 'abcd', 'cd'}\n"
     ]
    }
   ],
   "source": [
    "charSet = set()\n",
    "\n",
    "index = 0\n",
    "length = len(p)\n",
    "\n",
    "while index < length:\n",
    "    for i in range(length-index+1):\n",
    "        i = index + i\n",
    "        subString = p[index:i]\n",
    "        if subString != \"\":\n",
    "            charSet.add(subString)\n",
    "    index += 1\n",
    "\n",
    "print(charSet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import string\n",
    "\n",
    "def isInS(text):\n",
    "    if text == \"\":\n",
    "        return False\n",
    "    lowerCase = string.ascii_lowercase\n",
    "    length = len(lowerCase)\n",
    "    for theI, c in enumerate(text):\n",
    "        i = lowerCase.index(c)\n",
    "        iPlus = i + 1\n",
    "        if iPlus > length - 1:\n",
    "            iPlus = 0\n",
    "        if theI < len(text) - 1:\n",
    "            if lowerCase[iPlus] != text[theI+1]:\n",
    "                return False\n",
    "    return True\n",
    "\n",
    "isInS(\"zab\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isInS(\"ca\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isInS(\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/unique-substrings-in-wraparound-string\n",
    "\n",
    "\n",
    "Time Limit Exceeded\n",
    "\n",
    "\n",
    "```python\n",
    "import string\n",
    "\n",
    "def isInS(text):\n",
    "    if text == \"\": return False\n",
    "    lowerCase = string.ascii_lowercase\n",
    "    length = len(lowerCase)\n",
    "    for theI, c in enumerate(text):\n",
    "        i = lowerCase.index(c)\n",
    "        iPlus = i + 1\n",
    "        if iPlus > length - 1:\n",
    "            iPlus = 0\n",
    "        if theI < len(text) - 1:\n",
    "            if lowerCase[iPlus] != text[theI+1]:\n",
    "                return False\n",
    "    return True\n",
    "\n",
    "class Solution:\n",
    "    def findSubstringInWraproundString(self, p: str) -> int:\n",
    "        charSet = set()\n",
    "\n",
    "        index = 0\n",
    "        length = len(p)\n",
    "\n",
    "        while index < length:\n",
    "            for i in range(length-index+1):\n",
    "                i = index + i\n",
    "                subString = p[index:i]\n",
    "                if isInS(subString):\n",
    "                    charSet.add(subString)\n",
    "            index += 1\n",
    "        \n",
    "        return len(charSet)\n",
    "```\n",
    "\n",
    "\n",
    "\n",
    "Spent an hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
